package emissionsviewer;

import java.text.DecimalFormat;
import java.text.ParseException;

/**
 * Java sucks at parsing scientific notation, so had to make this class
 * to run a regex on every number before parsing...
 * @author matt
 */
public class SciNotationFormat extends DecimalFormat {
    private final DecimalFormat decimal;

    public SciNotationFormat(String pattern) {
        decimal = new DecimalFormat(pattern);
    }

    public Number parse(String s) throws ParseException {
        return decimal.parse(s.replace("E+", "E"));
    }
}
